package chapter02

object Test11_String2 {
  def main(args: Array[String]): Unit = {
    //回文字符串判断
    def f(s:String):Boolean={
      //将字符串反转
      var s1 = ""
      for(i<-s.length-1 to 0 by -1){
        s1+=s(i)
      }
      if(s==s1) true else false
    }
    println(f("abccba"))
    println(f("abc"))
    //使用函数方式将字符串反转
    def f1(s:String):Boolean={
      s==s.reverse
    }
    println(f1("abccba"))
    println(f1("abc"))
  }
}
